package com.itheima.mapper;

import com.itheima.pojo.Inventory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface InventoryMapper {
    @Select("select * from inventory,products where inventory.product_id = products.id")
    @Result(property = "productName",column = "name")
    @Result(property = "imageUrl",column = "image_url")
    List<Inventory> getInventories();

    @Insert("insert into inventory(product_id,stock,create_time,update_time) " +
            "values(#{id},100,#{createTime},#{updateTime})")
    void addInventory(int product);
}
